package cn.wolfcode.trip.api.controller;

import cn.wolfcode.trip.base.domain.MyTravelList;
import cn.wolfcode.trip.base.query.MycommentQueryObject;
import cn.wolfcode.trip.base.service.IMyTravelListService;
import cn.wolfcode.trip.base.service.IMycommentService;
import cn.wolfcode.trip.base.util.JsonResult;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("mytravellists")
public class MyTravelListController {
    @Autowired
    private IMyTravelListService travelListService;

    /**
     * 添加游记的接口
     * 1.资源 /mycomments
     * 2.请求方式 get
     * 3.请求参数 分页
     * 4.返回结果 JsonResult
     */
    @GetMapping("getTravelList/{userId}/{strategyId}")
    public JsonResult list(@PathVariable Long userId, @PathVariable Long strategyId ){
        JsonResult json=new JsonResult();

        MyTravelList myTravelList = travelListService.selectByUserIdAndStrategyId(userId, strategyId);

        if(myTravelList!=null){
            json.mark("凶爹,加入不了咯");
        }
        return json;
    }
    @PostMapping("save/{userId}/{strategyId}")
    public JsonResult save(MyTravelList travelList ){
        JsonResult json=new JsonResult();

        travelListService.saveRelation(travelList);

        return json;
    }
    @GetMapping("{userId}/strategies")
    public List<Map> getByUserId(@PathVariable Long userId){

        return travelListService.getByUserId(userId);

    }
}
